package weiyao;


import us.codecraft.webmagic.Site;

public class SiteManager {
    private Site currentSite;

    public SiteManager() {
        // 默认配置
        this.currentSite = Site.me()
                .setRetryTimes(1)
                .setSleepTime(1000)
                .setTimeOut(10000)
                .addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
                .addHeader("Accept-Language", "zh-CN,zh;q=0.9")
                .setUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36");
    }

    public void configureSite(String domain) {
        this.currentSite = this.currentSite.setDomain(domain);
    }

    public Site getCurrentSite() {
        return currentSite;
    }
}